/**
 * 
 */
package br.ufpe.cin.plebeia.gui;

import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JButton;

import br.ufpe.cin.plebeia.model.TipoDeColecao;
import br.ufpe.cin.plebeia.persistence.hibernateDao.HibernateTipoDeColecaoDao;

/**
 * @author bruno
 *
 */
public class InserirTipoDeColecao extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JLabel nomeBancoLabel = null;

	private JTextField nomeField = null;

	private JButton cancelar = null;

	private JButton inserir = null;

	/**
	 * This method initializes nomeField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getNomeField() {
		if (nomeField == null) {
			nomeField = new JTextField();
			nomeField.setBounds(new Rectangle(130, 15, 150, 20));
		}
		return nomeField;
	}

	/**
	 * This method initializes cancelar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCancelar() {
		if (cancelar == null) {
			cancelar = new JButton();
			cancelar.setBounds(new Rectangle(26, 60, 94, 29));
			cancelar.setText("Cancelar");
		}
		return cancelar;
	}

	/**
	 * This method initializes inserir	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getInserir() {
		if (inserir == null) {
			inserir = new JButton();
			inserir.setBounds(new Rectangle(174, 59, 103, 30));
			inserir.setText("Inserir");
			inserir.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
					HibernateTipoDeColecaoDao dao = new HibernateTipoDeColecaoDao();
					
					TipoDeColecao tipo = new TipoDeColecao();
					tipo.setNome(nomeField.getText());
					
					dao.save(tipo);
					
					
				}
			});
		}
		return inserir;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				InserirTipoDeColecao thisClass = new InserirTipoDeColecao();
				thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				thisClass.setVisible(true);
			}
		});
	}

	/**
	 * This is the default constructor
	 */
	public InserirTipoDeColecao() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(300, 139);
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			nomeBancoLabel = new JLabel();
			nomeBancoLabel.setBounds(new Rectangle(29, 17, 99, 15));
			nomeBancoLabel.setText("Nome do banco:");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(nomeBancoLabel, null);
			jContentPane.add(getNomeField(), null);
			jContentPane.add(getCancelar(), null);
			jContentPane.add(getInserir(), null);
		}
		return jContentPane;
	}

}  //  @jve:decl-index=0:visual-constraint="16,10"
